package java_9_9.Test_4;

import java.util.*;

public class Company {
    private String name;//公司名称
    private String addess;//公司地址
    private String tel;//公司电话
    private String fw;//经营范围
    Map <String ,Staff> m=new HashMap<>();

    public Company() {

    }
    public Company(String name, String addess, String tel, String fw) {
        this.name = name;
        this.addess = addess;
        this.tel = tel;
        this.fw = fw;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddess() {
        return addess;
    }

    public void setAddess(String addess) {
        this.addess = addess;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getFw() {
        return fw;
    }

    public void setFw(String fw) {
        this.fw = fw;
    }
    //招聘员工（要求工号不能重复）
    public boolean add(Staff staff){
        if (m.containsKey(staff.getJobNumber())){
            System.out.println("已有工号，不能够在注册");
            return false;
        }else{
            m.put(staff.getJobNumber(),staff);
            return true;
        }
    }
    //输出员工信息
    public void show(){
        Set<String> keySet = m.keySet();
        for (String x:keySet){
            Staff s = m.get(x);
            System.out.println(s);
        }
    }
    //辞退员工
    public boolean delet(String jobNumber){
        if (m.containsKey(jobNumber)){
            m.remove(jobNumber);
            return true;
        }else{
        }return false;
    }
    //统计公司人数
    public int rs(){
        return m.size();
    }
    //获得薪水最高的员工
    public Staff max(){
        List list=new ArrayList();
        Staff staff=null;
        Set<String> keySet = m.keySet();
        for (String x:keySet){
            staff=m.get(x);
            list.add(staff.getPay());
        }
        Comparable max = Collections.max(list);
        return staff;
    }

    @Override
    public String toString() {
        return "公司{" +
                "名字='" + name + '\'' +
                ", 地址='" + addess + '\'' +
                ", 电话='" + tel + '\'' +
                ", 经营范围='" + fw + '\'' +
                '}';
    }
    //找年龄最大的员工
    public Staff maxAge(){
        List list=new ArrayList();
        Set<String> keySet = m.keySet();
        Staff staff=null;
        for (String x:keySet){
            staff=m.get(x);
            list.add(staff);
        }
        Comparable max=Collections.max(list);
        return staff;
    }
}
